//=============================================================================

#ifndef ACHARACTER_H
  #define ACHARACTER_H

//=============================================================================

#include "aObject.h"

//=============================================================================

enum acrLife
{
  LIFE_LIFE = -128,
  LIFE_NONE = 0,
  LIFE_OVERALL = 1,
  LIFE_DEATH = 255
};

//=============================================================================

class aAttack
{
  public:
    aAttack() {range = 1.0f; timeout = 500;}
    ~aAttack() {};

  float range;
  DWORD timeout;
  aString name;
  aString animName;
};

//=============================================================================

enum acrRet
{
  CHAR_DONE = -128,
  CHAR_CANT_ADD_ATTACK_BAD_NAME,
  CHAR_CANT_ADD_ATTACK_BAD_ANIMATION_NAME,
  CHAR_CANT_ADD_ATTACK_BAD_RANGE,
  CHAR_CANT_ADD_ATTACK_TO_SMALL_TIMEOUT,
  CHAR_CANT_ADD_ATTACK_NO_SUCH_ANIMATION,
  CHAR_CANT_APPEND_ATTACK_BAD_NAME,
  CHAR_CANT_APPEND_ATTACK_BAD_ANIMATION_NAME,
  CHAR_CANT_APPEND_ATTACK_NO_SUCH_ANIMATION,
  CHAR_CANT_APPEND_ATTACK_BAD_RANGE,
  CHAR_CANT_APPEND_ATTACK_TO_SMALL_TIMEOUT,
  CHAR_CANT_APPEND_NO_SUCH_ATTACK,
  CHAR_COL_BAD_DATA_POINTER,
  CHAR_COL_BAD_VOLUME_SIZE,
  CHAR_ABS_BAD_DATA_POINTER
};

//=============================================================================

class aCharacter : virtual public aObject
{
  public:
    inline float acGetAttackRange(const aString& cap)       {if (acGetAttackByName(cap)) return acGetAttackByName(cap)->data.range; return 0;}
    inline DWORD acGetAttackTimeout(const aString& cap)     {if (acGetAttackByName(cap)) return acGetAttackByName(cap)->data.timeout; return 0;}
    inline aString acGetAttackAnim(const aString& cap)      {if (acGetAttackByName(cap)) return acGetAttackByName(cap)->data.animName; return aString("");}

    aCharacter(unsigned long setId);
      void aoObjectProcess();
      acrRet acAddAttack(aString cap, aString anm, float range, DWORD timeout);
      acrRet acAppendAttackData(aString cap, aString anm, float range, DWORD timeout);
      size_t acGetAttacksDataVolume()const;
      acrRet acCollectAttacksData(void* attack, size_t wholeSize)const;
      aotRet aoLoadObject(const aString& path);
      acrRet acAbsorbAttacksData(char* data);
    ~aCharacter();

  private:
    aItem<aAttack>* acGetAttackByName(const aString& cap);

  public:
    acrLife lifeType;

  private:
    aString classNick;
    aList<aAttack> attacks;
};

//=============================================================================

#endif

//=============================================================================
